package org.beaconframework.ext.rs.cxf;

import org.apache.cxf.configuration.jsse.TLSClientParameters;
import org.apache.cxf.jaxrs.client.Client;
import org.apache.cxf.jaxrs.client.ClientConfiguration;
import org.apache.cxf.jaxrs.client.WebClient;

import org.apache.cxf.transport.http.HTTPConduit;


public class SslUtil {

	public static void disableCertificateChecking(Client wc) {
		ClientConfiguration cc = WebClient.getConfig(wc);
		HTTPConduit conduit = cc.getHttpConduit();

		TLSClientParameters cp = conduit.getTlsClientParameters();
		if (cp != null) {
			cp = new TLSClientParameters();
		}
		cp.setDisableCNCheck(true);
		cp.setTrustManagers(org.beaconframework.util.CertificateVerificationControl
				.createTrustAllCertsX509TrustManagerArray());
		conduit.setTlsClientParameters(cp);
	}
}
